<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>(clib-support)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">(clib-support)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">CLib Support Library </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p ><a class="anchor" id="md_output_README_doxygen"></a> </p>
<h1><a class="anchor" id="autotoc_md1"></a>
Overview</h1>
<p >The CLib Support Library provides the necessary hooks to make C library functions such as malloc and free thread safe. This implementation supports FreeRTOS and ThreadX and requires the appropriate RTOS to be present to build. For details on what this library provides see the toolchain specific documentation at:</p><ul>
<li>ARM: <a href="https://developer.arm.com/docs/100073/0614/the-arm-c-and-c-libraries/multithreaded-support-in-arm-c-libraries/management-of-locks-in-multithreaded-applications">https://developer.arm.com/docs/100073/0614/the-arm-c-and-c-libraries/multithreaded-support-in-arm-c-libraries/management-of-locks-in-multithreaded-applications</a></li>
<li>GCC: <a href="https://sourceware.org/newlib/libc.html#g_t_005f_005fmalloc_005flock">https://sourceware.org/newlib/libc.html#g_t_005f_005fmalloc_005flock</a></li>
<li>IAR: <a href="http://supp.iar.com/filespublic/updinfo/011261/arm/doc/EWARM_DevelopmentGuide.ENU.pdf">http://supp.iar.com/filespublic/updinfo/011261/arm/doc/EWARM_DevelopmentGuide.ENU.pdf</a></li>
</ul>
<p >The startup code must call cy_toolchain_init (for GCC and IAR). This must occur after static data initialization and before static constructors. This is done automatically for PSoC™ devices. See the PSoC™ startup files for an example.</p>
<p >In FreeRTOS to enable Thread Local Storage, configUSE_NEWLIB_REENTRANT must be enabled.</p>
<p >While this is specific to FreeRTOS and ThreadX, it can be used as a basis for supporting other RTOSes as well.</p>
<h1><a class="anchor" id="autotoc_md2"></a>
FreeRTOS Requirements</h1>
<p >To use this library, the following configuration options must be enabled in FreeRTOSConfig.h:</p><ul>
<li>configUSE_MUTEXES</li>
<li>configUSE_RECURSIVE_MUTEXES</li>
<li>configSUPPORT_STATIC_ALLOCATION</li>
</ul>
<h1><a class="anchor" id="autotoc_md3"></a>
ThreadX Requirements</h1>
<p >To use this library, the following configuration option must be enabled:</p><ul>
<li>TX_DISABLE_REDUNDANT_CLEARING</li>
</ul>
<p >When building with IAR, the '&ndash;threaded_lib' argument must be provided when linking. This is done automatically with psoc6make 1.3.1 and later. Also, 'TX_ENABLE_IAR_LIBRARY_SUPPORT' must be defined in the application when building with IAR. This enables the ThreadX IAR-specific port for clib thread safety. For more information about porting with ThreadX, see the ThreadX GitHub: <a href="https://github.com/azure-rtos/threadx/tree/master/ports">https://github.com/azure-rtos/threadx/tree/master/ports</a></p>
<h1><a class="anchor" id="autotoc_md4"></a>
Features</h1>
<ul>
<li>GCC Newlib implementations for:<ul>
<li>_sbrk</li>
<li>__malloc_lock</li>
<li>__malloc_unlock</li>
<li>__env_lock</li>
<li>__env_unlock</li>
</ul>
</li>
<li>ARM C library implementations for:<ul>
<li>_platform_post_stackheap_init</li>
<li>__user_perthread_libspace</li>
<li>_mutex_initialize</li>
<li>_mutex_acquire</li>
<li>_mutex_release</li>
<li>_mutex_free</li>
<li>_sys_exit</li>
<li>$Sub$$_sys_open</li>
<li>_ttywrch</li>
<li>_sys_command_string</li>
</ul>
</li>
<li>IAR C library implementations for:<ul>
<li>__aeabi_read_tp (FreeRTOS)</li>
<li>_reclaim_reent</li>
<li>__iar_system_Mtxinit (FreeRTOS)</li>
<li>__iar_system_Mtxlock (FreeRTOS)</li>
<li>__iar_system_Mtxunlock (FreeRTOS)</li>
<li>__iar_system_Mtxdst (FreeRTOS)</li>
<li>__iar_file_Mtxinit</li>
<li>__iar_file_Mtxlock</li>
<li>__iar_file_Mtxunlock</li>
<li>__iar_file_Mtxdst</li>
<li>__iar_Initdynamiclock</li>
<li>__iar_Lockdynamiclock</li>
<li>__iar_Unlockdynamiclock</li>
<li>__iar_Dstdynamiclock</li>
<li>__close</li>
<li>__lseek</li>
<li>remove</li>
</ul>
</li>
<li>C++ implementations for:<ul>
<li>__cxa_guard_acquire</li>
<li>__cxa_guard_abort</li>
<li>__cxa_guard_release</li>
</ul>
</li>
<li>time function implementation from time.h</li>
</ul>
<h2><a class="anchor" id="autotoc_md5"></a>
Time Support Details</h2>
<p >When using the HAL the <b>time</b> function returns the time in seconds from microcontroller Real-Time Clock (RTC). Additionally, functions <b>mtb_clib_support_init</b> and <b>mtb_clib_support_get_rtc</b> are provided to interact with the CLIB support RTC handle used. Follow below steps to set this up.</p><ol type="1">
<li>Setup using an existing CLIB support RTC handle:<ul>
<li>Application initializes RTC handle using PDL API</li>
<li>Application writes the current time to RTC using PDL API</li>
<li>Application sets the CLIB support RTC handle using <b>mtb_clib_support_init</b> API</li>
<li>Application calls <b>time</b> function to get the time from CLIB support RTC</li>
</ul>
</li>
</ol>
<p >NOTE: For <code>MTB_HAL_API_VERSION &gt;= 3</code>, <b>mtb_clib_support_init</b> must be called before <b>time</b> is invoked. Otherwise, <b>time</b> will assert and (if asserts are enabled) and return a default time value.</p>
<h1><a class="anchor" id="autotoc_md6"></a>
More information</h1>
<p >Use the following links for more information, as needed:</p><ul>
<li><a href="https://infineon.github.io/clib-support/html/index.html">Reference Guide</a></li>
<li><a href="http://www.cypress.com">Cypress Semiconductor, an Infineon Technologies Company</a></li>
<li><a href="https://github.com/infineon">Infineon GitHub</a></li>
<li><a href="https://www.cypress.com/products/modustoolbox-software-environment">ModusToolbox™</a></li>
<li><a href="https://github.com/infineon/mtb-hal-cat1/blob/master/include/mtb_hal_rtc.h">RTC APIs</a></li>
</ul>
<hr  />
<p> © Cypress Semiconductor Corporation (an Infineon company) or an affiliate of Cypress Semiconductor Corporation, 2020-2021. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>(clib-support)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
